package com.example.myproject.redis.redission.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;
@Service
public class RedisOpsValueClient {
    @Autowired
    private RedisTemplate coredisFrameTemplate;

    public RedisOpsValueClient() {
    }

    public Object get(String key) {
        return this.coredisFrameTemplate.opsForValue().get(key);
    }

    public Object getAndSet(String key, Object value) {
        return this.coredisFrameTemplate.opsForValue().getAndSet(key, value);
    }

    public long increment(String key, long delta) {
        return this.coredisFrameTemplate.opsForValue().increment(key, delta);
    }

    public void set(String key, Object value) {
        this.coredisFrameTemplate.opsForValue().set(key, value);
    }

    public void set(String key, Object value, long timeout, TimeUnit timeUnit) {
        this.coredisFrameTemplate.opsForValue().set(key, value, timeout, timeUnit);
    }

    public boolean setIfAbsent(String key, Object value) {
        return this.coredisFrameTemplate.opsForValue().setIfAbsent(key, value);
    }
}
